package net.shenru.os.task;

import net.shenru.os.utlis.UniqueIdGenerator;

/**
 * 任务：任务有异步和同步任务
 */
public class Task implements ITask {

	/** 任务Id */
	private long id;
	/** 任务标签 */
	private Object tag;
	/** 任务状态 */
	private TaskStatue statue;
	/** 任务类型 */
	private TaskType type;
	/** 任务实体 */
	private TaskBundle bundle;

	public Task() {
		this(UniqueIdGenerator.getInstance().getLongId());
	}

	public Task(long id) {
		this(id, TaskType.Normal, TaskStatue.Prepare);
	}

	public Task(long id, TaskType type, TaskStatue statue) {
		this(id, type, statue, null, null);
	}

	public Task(long id, TaskType type, TaskStatue statue, Object tag, TaskBundle bundle) {
		this.id = id;
		this.statue = statue;
		this.type = type;
		this.tag = tag;
		this.bundle = bundle;
	}

	/*
	 * 任务Id
	 * 
	 * @see net.shenru.os.task.ITask#getId()
	 */
	@Override
	public long getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#setId(int)
	 */
	@Override
	public void setId(long id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#getTag()
	 */
	@Override
	public Object getTag() {
		return tag;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#setTag(java.lang.Object)
	 */
	@Override
	public void setTag(Object tag) {
		this.tag = tag;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#getStatue()
	 */
	@Override
	public TaskStatue getStatue() {
		return statue;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#setStatue(net.shenru.os.task.TaskStatue)
	 */
	@Override
	public void setStatue(TaskStatue statue) {
		this.statue = statue;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#getType()
	 */
	@Override
	public TaskType getType() {
		return type;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.shenru.os.task.ITask#setType(net.shenru.os.task.TaskType)
	 */
	@Override
	public void setType(TaskType type) {
		this.type = type;
	}

	@Override
	public void setTaskBundle(TaskBundle bundle) {
		this.bundle = bundle;
	}

	@Override
	public TaskBundle getTaskBundle() {
		return bundle;
	}

}
